#pragma once
#include<iostream>
#include<string>
#include<pthread.h>


using namespace std;
typedef void*(*func_t)(void*);//线程中的回调函数

class threadData
{
public:
    string _name;
    void* _args;
};


class Thread
{
public:
    Thread(int inode,func_t routine, void* args)
        :_routine_func(routine)
    {
        char buffer[64]="";
        snprintf(buffer,sizeof(buffer),"thread-%d",inode);
        _name = buffer;
        _tdata._name = _name;
        _tdata._args = args;
    }

    ~Thread(){}

    void Start()
    {
        pthread_create(&_tid,nullptr,_routine_func,(void*)&_tdata);
    }


    void Join()
    {
        pthread_join(_tid,nullptr);
    }

private:
    string _name;//线程名
    pthread_t _tid;//线程ID
    func_t _routine_func;
    threadData _tdata;
};